package moodish.server;

import java.util.LinkedList;

/**
 * This class represents the data-type that stores a connected client's
 * information on the server. It cannot be accessed externally
 * 
 * <br>
 * It stores:
 * <ul>
 * <li>A nickname
 * <li>A <b>connected</b> flag
 * <li>Friends lists
 */
public class Client {

	/** A client's nickname */
	public String nickname;

	/** Representing the client's connection state */
	public boolean connected = false;

	/** A list containing the names of clients who this client is following */
	public LinkedList<String> followerOf = new LinkedList<String>();

	/** A list containing the names of clients followd by this client */
	public LinkedList<String> followedBy = new LinkedList<String>();

	/**
	 * Instantiates a new client.
	 * 
	 * @param nickname
	 *            the nickname of the Client
	 */
	public Client(String nickname) {

		this.nickname = nickname;

	}

	/**
	 * Gets the nickname.
	 * 
	 * @return the nickname
	 */
	public String getNickname() {
		return this.nickname;
	}

	/**
	 * Adds a Client who this client is following.
	 * 
	 * @param nickname
	 *            the nickname
	 */
	public void addFollower(String nickname) {
		this.followerOf.add(nickname);
	}

	/**
	 * Adds the client who is following this client.
	 * 
	 * @param nickname
	 *            the nickname
	 */
	public void addFollowedBy(String nickname) {
		this.followedBy.add(nickname);
	}

	/**
	 * Removes the follower of.
	 * 
	 * @param nickname
	 *            the nickname
	 */
	public void removeFollowerOf(String nickname) {
		this.followerOf.remove(nickname);
	}

	/**
	 * Removes the followed by.
	 * 
	 * @param nickname
	 *            the nickname
	 */
	public void removeFollowedBy(String nickname) {
		this.followedBy.remove(nickname);
	}

	/**
	 * Checks if is follower of.
	 * 
	 * @param nickname
	 *            the nickname
	 * @return true, if is follower of
	 */
	public boolean isFollowerOf(String nickname) {
		return this.followerOf.contains(nickname);
	}

	/**
	 * Checks if is followed by.
	 * 
	 * @param nickname
	 *            the nickname
	 * @return true, if is followed by
	 */
	public boolean isFollowedBy(String nickname) {
		return this.followedBy.contains(nickname);
	}

}